<template>
    <div>
        <p class="title">推荐歌单</p>
        <van-row gutter="5">
            <!-- diff算法 -->
            <van-col span="8" v-for="item in list" :key="item.id">
                <van-image width="100%" height="4rem" fit="cover" :src="item.picUrl" />
                <p class="song_name">{{ item.name }}</p>
            </van-col>
        </van-row>
        <p class="title">最新音乐</p>
        <van-cell center :title="item1.name" :label="item1.song.artists[0].name+'-'+item1.name"  v-for="item1 in newList" :key="item1.id">
            <!-- 使用 right-icon 插槽来自定义右侧图标 -->
            <template #right-icon>
                <van-icon name="play-circle-o" size="0.7rem" />
            </template>
        </van-cell>
    </div>
</template>
<script>
export default {
    data() {
        return {
            list: [],//推荐歌单
            newList:[],///最新音乐
        }
    },
    methods: {
        
        async getList() {
            // const { data: res } = await recommendedMusicAPI({limit:6})
            // console.log("🚀 ~ file: index.vue:14 ~ getList ~ res", res);
            // this.list = res.result
            // console.log("🚀 ~ file: index.vue:21 ~ getList ~ list", this.list);
           this.$http.get('/personalized?limit=6').then(res => {
                // console.log(res,'res');
                this.list = res.data.result
                // console.log("🚀 ~ file: index.vue:23 ~ this.$http.get ~ this.list", this.list);
            })
             const {data:res1} = await this.$http.get('/personalized/newsong',{params:{limit:30}})
            //  console.log("🚀 ~ file: index.vue:41 ~ getList ~ res1", res1);
             this.newList = res1.result
             console.log(this.newList[0].song.artists[0].name);
             
        }
    },
    mounted() {
        this.getList();
    }
}
</script>

<style lang="scss" scoped>
/* 标题 */
.title {
    padding: 0.266667rem 0.24rem;
    margin: 0 0 0.24rem 0;
    background-color: #eee;
    color: #333;
    font-size: 15px;
}

/* 推荐歌单 - 歌名 */
.song_name {
    font-size: 0.346667rem;
    padding: 0 0.08rem;
    margin-bottom: 0.266667rem;
    word-break: break-all;
    text-overflow: ellipsis;
    display: -webkit-box;
    /** 对象作为伸缩盒子模型显示 **/
    -webkit-box-orient: vertical;
    /** 设置或检索伸缩盒对象的子元素的排列方式 **/
    -webkit-line-clamp: 2;
    /** 显示的行数 **/
    overflow: hidden;
    /** 隐藏超出的内容 **/
}
</style>